<?php
class Jbarang_model extends CI_Model {

    var $tabel    = 't_jbarang';

    function __construct() {
        parent::__construct();
		$this->load->library('encrypt');
    }
    
    function get_count($options=array())
    {
		$this->db->like($options);
        $query = $this->db->get($this->tabel);
		return count($query->result_array());
    }

    function get_data()
    {
		//$this->db->like($options);
        $query = $this->db->get($this->tabel);
        return $query->result();
    }


 	function get_data_row($kd){
		$data = array();
		$options = array('kd_jbarang' => $kd);
		$query = $this->db->get_where($this->tabel,$options,1);
		if ($query->num_rows() > 0){
			$data = $query->row_array();
		}

		$query->free_result();    
		return $data;
	}

   function insert_entry()
    {
		$data['kd_jbarang']=$this->input->post('kd_jbarang');
		$data['nm_jbarang']=$this->input->post('nm_jbarang');
		
		return $this->db->insert($this->tabel, $data);
    }

    function update_entry($kd)
    {
		$data['kd_jbarang']=$this->input->post('kd_jbarang');
        
		return $this->db->update($this->tabel, $data, array('kd_jbarang' => $kd));
    }
	

	function delete_entry($kd)
	{
		$this->db->where(array('kd_jbarang' => $kd));

		return $this->db->delete($this->tabel);
	}

}